package com.example.mobile2021606144ywr0427;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class StopRVAdapter extends RecyclerView.Adapter<StopRVAdapter.ViewHolder>{
    private List<Stop>list;
    public StopRVAdapter(List<Stop>list){
        this.list=list;
    }
    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext())
                .inflate(R.layout.rv_main_stop,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        Stop stop=list.get(position);
        holder.tvName.setText(stop.getName());
        holder.tvKw.setText(stop.getKw());
        holder.tvJuli.setText(stop.getJuli());
        holder.tvJiage.setText(stop.getJiage());
        holder.tvdizhi.setText(stop.getDizhi());

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder{
        TextView tvName,tvKw,tvJuli,tvJiage,tvdizhi;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tvName=itemView.findViewById(R.id.tv_stopname);
            tvKw=itemView.findViewById(R.id.tv_kw);
            tvJuli=itemView.findViewById(R.id.tv_juli);
            tvJiage=itemView.findViewById(R.id.tv_jiage);
            tvdizhi=itemView.findViewById(R.id.tv_dizhi);
        }
    }
}
